<%@ Page Language="C#" AutoEventWireup="true" CodeFile="GonzalesMyDraftDetailExpand.aspx.cs" Inherits="GonzalesMyDraftDetailExpand" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
    <link href="WebStyle.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" language="javascript" src="js/popcalendar.js"></script>
<script type="text/javascript" language="javascript" src="js/common.js"></script>


<script language="javascript" type="text/javascript">

    function Validate() {
        
        var valid = true;
        
        //Calcuate Amount Left Over
        CalculateLeftOver();
        
        
        // validate amount        
        var TotalAmountStated = 0;
        
        for(var x = 0; x < document.forms[0].elements.length; x++) {
            if (document.forms[0].elements[x].name.indexOf ("_TextBoxAmount") > 0) {
				TotalAmountStated += parseFloat(document.forms[0].elements[x].value.replace(/,/g,''));
			}
        }
        valid = (Round(TotalAmountStated, 2) != Round(TotalAmountClaimed, 2))?false:valid;
        
        if (!valid) alert(AmountValidateMessage);
        
        return valid;
    }
	
	function CalculateLeftOver () {
	
        // validate amount        
        var TotalAmountStated = 0;
        
        for(var x = 0; x < document.forms[0].elements.length; x++) {
            if (document.forms[0].elements[x].name.indexOf ("_TextBoxAmount") > 0) {
				TotalAmountStated += parseFloat(document.forms[0].elements[x].value.replace(/,/g,''));
			}
        }
		document.getElementById("LabelValue_AmountLeft").innerHTML = FormatCurrency(TotalAmountClaimed - TotalAmountStated);
	
	}
	
	function EventAmountOnChange (Obj) {

		
		if (isNaN(Obj.value)) {
			Obj.value = Obj.defaultValue;
		} else {
			CalculateLeftOver();
			
			if (parseFloat(document.getElementById("LabelValue_AmountLeft").innerHTML.replace(/,/g,'')) < 0) {
				Obj.value = Obj.defaultValue;			
				CalculateLeftOver();			
			} else {
				Obj.defaultValue = Obj.value;			
			}

		}
		
		
	}

</script>
</head>
<body>
<form id="form1" runat="server">
  <div>
    <table width="100%" border="0" cellspacing="1" cellpadding="8">
      <tr>
        <td class="PageTitle"><asp:Label ID="Label_PageTitle" Text='Expense' runat="server" />
        </td>
      </tr>
      <tr>
        <td><table width="100%" border="0" cellspacing="1" cellpadding="2">
          <tr>
            <td width="170" rowspan="4" valign="top"><asp:Label CssClass="FormTitle" ID="Label_Information" runat="server" Text='Extend of draft item' />            
              <p>
              <asp:Label CssClass="NormalBodyText" ID="Label_Remarks" runat="server" Text='Proceed with providing more details for the claim item' /></p></td>
            <td width="8" rowspan="4" class="VerticalDivider">&nbsp;</td>
            <td colspan="2" valign="top"><asp:Table CellPadding="5" CellSpacing="0" ID="Table_MessageBox" Width="100%" runat="server" Visible="false">
              <asp:TableRow>
                <asp:TableCell CssClass="ErrorBox" ></asp:TableCell>
              </asp:TableRow>
            </asp:Table></td>
          </tr>
          <tr>
            <td colspan="2" valign="top"><table width="100%" border="0" cellpadding="5" cellspacing="0" class="FormBorder">
              <tr>
                <td colspan="4" align="right" class="FormLineItemAlt"><asp:ImageButton ID="ImageButton_Cancel" runat="server" ImageUrl="~/img/popcalendar/close.gif"
                            OnClick="ImageButton_Cancel_Click" /></td>
              </tr>
              <tr>
                <td width="140" class="FormLineItem"><asp:Label CssClass="FormField" ID="Label_Item" runat="server" Text='Expense Detail:' /></td>
                <td width="39%" class="FormLineItem"><asp:Label CssClass="NormalBodyText" ID="LabelValue_ExpenseDetail" runat="server" /></td>
                <td width="140" class="FormLineItem"><asp:Label CssClass="FormField" ID="Label_ClaimedAmount" runat="server" Text='Amount claimed:' /></td>
                <td width="29%" class="FormLineItem"><asp:Label CssClass="NormalBodyText" ID="LabelValue_AmountClaimed" runat="server" /></td>
              </tr>
              <tr>
                <td class="FormLineItemAlt"><asp:Label CssClass="FormField" ID="Label_Description" runat="server" Text='Description:' /></td>
                <td class="FormLineItemAlt"><span class="FormLineItem">
                  <asp:Label CssClass="NormalBodyText" ID="LabelValue_Description" runat="server" />                  
</span></td>
                <td class="FormLineItemAlt"><asp:Label CssClass="FormField" ID="Label_ItemRemark" runat="server" Text='Remarks:' /></td>
                <td class="FormLineItemAlt"><asp:Label CssClass="NormalBodyText" ID="LabelValue_Remarks" runat="server" /></td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td valign="top"><asp:Table ID="Table_ClaimDetailGrid" runat="server" Width="100%" CellPadding="0" CellSpacing="1" CssClass="FormBorder"> </asp:Table></td>
            <td width="350" align="right" valign="top"><table width="100%" border="0" cellpadding="5" cellspacing="1" class="FormBorder">
              <tr>
                <td class="FormLineItem"><asp:Label CssClass="FormField" ID="Label_AmoutLeft" runat="server" Text="Amount Left:" /></td>
                <td width="183" class="FormLineItem"><asp:Label CssClass="MessageInformation" ID="LabelValue_AmountLeft" runat="server" /></td>
              </tr>
              <tr>
                <td colspan="2" class="FormLineItemAlt">&nbsp;</td>
              </tr>
              <tr>
                <td class="FormLineItem"><asp:Label ID="Label_DetailType" runat="server" CssClass="FormField" Text='Expense Detail:'></asp:Label></td>
                <td class="FormLineItem"><asp:DropDownList ID="DropDownList_DetailType" runat="server" CssClass ="FormDropDown"></asp:DropDownList><input type="hidden" runat="server" id="HiddenRemarks" /></td>
              </tr>
              <tr>
                <td colspan="2" class="FormLineItemAlt">&nbsp;</td>
              </tr>
              <tr>
                <td width="100" class="FormLineItem"><asp:Label CssClass="FormField" ID="Label_DateRange" runat="server" Text='Date Range:' /></td>
                <td class="FormLineItem"><asp:TextBox CssClass="FormTextBox" ID="TextBox_DateFrom" runat="server" TextMode="SingleLine" MaxLength="50" Columns="10" />&nbsp;<img src="img/calendar.gif" runat="server" id="img_calendarFrom" style="vertical-align:middle;"/>                
                  <asp:Label CssClass="NormalBodyText" ID="Label_To" runat="server" Text="to" />                  
                  <asp:TextBox CssClass="FormTextBox" ID="TextBox_DateTo" runat="server" TextMode="SingleLine" MaxLength="50" Columns="10" />&nbsp;<img src="img/calendar.gif" id="img_calendarTo" runat="server" style="vertical-align:middle;" /></td>
              </tr>
              <tr>
                <td class="FormLineItemAlt"><asp:Label CssClass="FormField" ID="Label_DailyRate2" Text='Daily Rate:' runat="server" /></td>
                <td class="FormLineItemAlt"><asp:TextBox CssClass="FormTextBox" ID="TextBox_DailyRate" runat="server" TextMode="SingleLine" MaxLength="10" Columns="10" Text='0' /></td>
              </tr>
              <tr>
                <td colspan="2" class="FormLineItem"><asp:Button ID="Button_Next" Text="Auto Populate" runat="server" OnClick="Button_Next_Click" CssClass="FormButton" />                </td>
              </tr>
            </table></td>
          </tr>
          
          <tr>
            <td colspan="2" valign="top"><asp:Button CssClass="FormButton" ID="Button_Delete" runat="server" Text="Remove Selected Items" OnClick="Button_Delete_Click" /> 
            <asp:Button ID="Button_Reset" Text="Clear All Items" runat="server" OnClick="Button_Reset_Click" CssClass="FormButton" /> 
            <asp:Button ID="Button_AddMoreLine" runat="server" CssClass="FormButton" OnClick="Button_AddMoreLine_Click"
                    Text="Add More Items" />
            <asp:Button CssClass="FormButton" ID="Button_Save" runat="server" Text="Save" OnClick="Button_Save_Click" />            
            <asp:Button CssClass="FormButton" ID="Button_SaveNExit" runat="server" Text="Save & Exit" OnClick="Button_SaveNExit_Click" /> 
              <asp:Button CssClass="FormButton" ID="Button_Cancel" runat="server" Text="Cancel" OnClick="Button_Cancel_Click" /></td>
            </tr>
        </table></td>
      </tr>
    </table>
  </div>
</form>
</body>
<script language="javascript" type="text/javascript">
CalculateLeftOver();
</script>
</html>
